package no.hio.wsprovider.dao;

import java.util.List;

import no.hio.wsprovider.vo.Identifier;
/**
 * Provides common utilities for DAO classes. Probably belongs somewhere else.
 * 
 * @author andreas
 * @version 1.0
 */
public class Util {
	
	/**
	 * Calculates maximum identifier + 1.
	 * @see Identifier
	 * @param <T> any object implementing Identifier
	 * @param list List of objects type T
	 * @return next productID
	 */
	public static <T extends Identifier> int getNextIdentifier(List<T> list)
	{
		
		int nextID = 0; //in case of empty list, id must at least be 1.
		
		for(T t : list)
		{
			if(t.getIdentifier() > nextID) nextID = t.getIdentifier();
		}
		
		nextID++;
		return nextID;
		
	}

}
